package com.zjj.day0425.regex;

/**
 * @author zhoujunjie
 * @desc TODO
 * @date 2025/4/25
 */
import java.util.regex.Pattern;

class Person {
    private String name;
    private String gender;
    private int age;
    private String qqNumber;

    public Person(String name, String gender, int age, String qqNumber) {
        this.name = name;
        this.gender = gender;
        this.age = age;
        this.qqNumber = qqNumber;
    }

    @Override
    public String toString() {
        return "姓名: " + name + ", 性别: " + gender + ", 年龄: " + age + ", QQ 号码: " + qqNumber;
    }

    public String getQqNumber() {
        return qqNumber;
    }
}

public class PersonInfoParsing {
    public static void main(String[] args) {
        String text = "  anglebaby          女          18          515151511  ";
        String[] parts = text.trim().split("\\s+");
        String name = parts[0];
        String gender = parts[1];
        int age = Integer.parseInt(parts[2]);
        String qqNumber = parts[3];

        Person person = new Person(name, gender, age, qqNumber);
        System.out.println("这个人的信息: " + person);

        if (isValidQQNumber(qqNumber)) {
            System.out.println("QQ 号合法。");
        } else {
            System.out.println("QQ 号不合法。");
        }
    }

    public static boolean isValidQQNumber(String qqNumber) {

        String regex = "^[1-9]\\d{4,11}$";
        return Pattern.matches(regex, qqNumber);
    }
}